# !/usr/bin/env python
# !-*-coding:utf-8 -*-
# !@TIME: 2021/3/11 17:50
# !@Author : Destroy丶寒露
# !@File :.py

import requests
import parsel


class Biquge:

    def __init__(self, url):
        self.url = url

    def start(self, visitweb):
        #self.driver.get('http://www.xbiquge.la/paihangbang/')
        # 5.获取所有章节的网址
        response = requests.get(self.url)
        # 防止乱码出现
        response.encoding = response.apparent_encoding
        sel = parsel.Selector(response.text)
        url1 = sel.css('#main > div:nth-child(2) > ul:nth-child(2) > li > a::attr(href)').extract()  # 返回值h1是个对象
        title = sel.css('#main > div:nth-child(2) > ul:nth-child(2) > li > a::text').extract()  # 返回值h1是个对象

        i = 0
        for url in url1:
            book_list = {'1_No': '', '2_name': '', '3_link': ''}
            info = [visitweb.data_num, title[i], url]
            visitweb.data_num += 1
            book_list = dict(zip(book_list.keys(), info))
            visitweb.info_list.append(book_list)
            i += 1





